home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 34.zip / BS1 part 34 / Music Util v1.5 TPL.adf / NOISEREPLAY.s < prev    next >
Text File  |  1987-05-04  |  8KB  |  479 lines

  1.  
  2. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  3. ;­   NoisetrackerV1.0 replayroutine   ­
  4. ;­ Mahoney & Kaktus - HALLONSOFT 1989 ­
  5. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  6.  
  7. mt_data=$58000
  8.  
  9. mt_init:lea    mt_data,a0
  10.     move.l    a0,a1
  11.     add.l    #$3b8,a1
  12.     moveq    #$7f,d0
  13.     moveq    #0,d1
  14. mt_loop:move.l    d1,d2
  15.     subq.w    #1,d0
  16. mt_lop2:move.b    (a1)+,d1
  17.     cmp.b    d2,d1
  18.     bgt.s    mt_loop
  19.     dbf    d0,mt_lop2
  20.     addq.b    #1,d2
  21.  
  22.     lea    mt_samplestarts(pc),a1
  23.     asl.l    #8,d2
  24.     asl.l    #2,d2
  25.     add.l    #$43c,d2
  26.     add.l    a0,d2
  27.     move.l    d2,a2
  28.     moveq    #$1e,d0
  29. mt_lop3:clr.l    (a2)
  30.     move.l    a2,(a1)+
  31.     moveq    #0,d1
  32.     move.w    42(a0),d1
  33.     asl.l    #1,d1
  34.     add.l    d1,a2
  35.     add.l    #$1e,a0
  36.     dbf    d0,mt_lop3
  37.  
  38.     or.b    #$2,$bfe001
  39.     move.b    #$6,mt_speed
  40.     clr.w    $dff0a8
  41.     clr.w    $dff0b8
  42.     clr.w    $dff0c8
  43.     clr.w    $dff0d8
  44.     clr.b    mt_songpos
  45.     clr.b    mt_counter
  46.     clr.w    mt_pattpos
  47.     rts
  48.  
  49. mt_end:    clr.w    $dff0a8
  50.     clr.w    $dff0b8
  51.     clr.w    $dff0c8
  52.     clr.w    $dff0d8
  53.     move.w    #$f,$dff096
  54.     rts
  55.  
  56. mt_music:
  57.     movem.l    d0-d4/a0-a3/a5-a6,-(a7)
  58.     lea    mt_data,a0
  59.     addq.b    #$1,mt_counter
  60.     move.b    mt_counter,D0
  61.     cmp.b    mt_speed,D0
  62.     blt.s    mt_nonew
  63.     clr.b    mt_counter
  64.     bra    mt_getnew
  65.  
  66. mt_nonew:
  67.     lea    mt_voice1(pc),a6
  68.     lea    $dff0a0,a5
  69.     bsr    mt_checkcom
  70.     lea    mt_voice2(pc),a6
  71.     lea    $dff0b0,a5
  72.     bsr    mt_checkcom
  73.     lea    mt_voice3(pc),a6
  74.     lea    $dff0c0,a5
  75.     bsr    mt_checkcom
  76.     lea    mt_voice4(pc),a6
  77.     lea    $dff0d0,a5
  78.     bsr    mt_checkcom
  79.     bra    mt_endr
  80.  
  81. mt_arpeggio:
  82.     moveq    #0,d0
  83.     move.b    mt_counter,d0
  84.     divs    #$3,d0
  85.     swap    d0
  86.     cmp.w    #$0,d0
  87.     beq.s    mt_arp2
  88.     cmp.w    #$2,d0
  89.     beq.s    mt_arp1
  90.  
  91.     moveq    #0,d0
  92.     move.b    $3(a6),d0
  93.     lsr.b    #4,d0
  94.     bra.s    mt_arp3
  95. mt_arp1:moveq    #0,d0
  96.     move.b    $3(a6),d0
  97.     and.b    #$f,d0
  98.     bra.s    mt_arp3
  99. mt_arp2:move.w    $10(a6),d2
  100.     bra.s    mt_arp4
  101. mt_arp3:asl.w    #1,d0
  102.     moveq    #0,d1
  103.     move.w    $10(a6),d1
  104.     lea    mt_periods(pc),a0
  105.     moveq    #$24,d7
  106. mt_arploop:
  107.     move.w    (a0,d0.w),d2
  108.     cmp.w    (a0),d1
  109.     bge.s    mt_arp4
  110.     addq.l    #2,a0
  111.     dbf    d7,mt_arploop
  112.     rts
  113. mt_arp4:move.w    d2,$6(a5)
  114.     rts
  115.  
  116. mt_getnew:
  117.     lea    mt_data,a0
  118.     move.l    a0,a3
  119.     move.l    a0,a2
  120.     add.l    #$c,a3
  121.     add.l    #$3b8,a2
  122.     add.l    #$43c,a0
  123.  
  124.     moveq    #0,d0
  125.     move.l    d0,d1
  126.     move.b    mt_songpos,d0
  127.     move.b    (a2,d0.w),d1
  128.     asl.l    #8,d1
  129.     asl.l    #2,d1
  130.     add.w    mt_pattpos,d1
  131.     clr.w    mt_dmacon
  132.  
  133.     lea    $dff0a0,a5
  134.     lea    mt_voice1(pc),a6
  135.     bsr.s    mt_playvoice
  136.     lea    $dff0b0,a5
  137.     lea    mt_voice2(pc),a6
  138.     bsr.s    mt_playvoice
  139.     lea    $dff0c0,a5
  140.     lea    mt_voice3(pc),a6
  141.     bsr.s    mt_playvoice
  142.     lea    $dff0d0,a5
  143.     lea    mt_voice4(pc),a6
  144.     bsr.s    mt_playvoice
  145.     bra    mt_setdma
  146.  
  147. mt_playvoice:
  148.     move.l    (a0,d1.l),(a6)
  149.     addq.l    #4,d1
  150.     moveq    #0,d2
  151.     move.b    $2(a6),d2
  152.     and.b    #$f0,d2
  153.     lsr.b    #4,d2
  154.     move.b    (a6),d0
  155.     and.b    #$f0,d0
  156.     or.b    d0,d2
  157.     tst.b    d2
  158.     beq.s    mt_setregs
  159.     moveq    #0,d3
  160.     lea    mt_samplestarts(pc),a1
  161.     move.l    d2,d4
  162.     subq.l    #$1,d2
  163.     asl.l    #2,d2
  164.     mulu    #$1e,d4
  165.     move.l    (a1,d2.l),$4(a6)
  166.     move.w    (a3,d4.l),$8(a6)
  167.     move.w    $2(a3,d4.l),$12(a6)
  168.     move.w    $4(a3,d4.l),d3
  169.     tst.w    d3
  170.     beq.s    mt_noloop
  171.     move.l    $4(a6),d2
  172.     asl.w    #1,d3
  173.     add.l    d3,d2
  174.     move.l    d2,$a(a6)
  175.     move.w    $4(a3,d4.l),d0
  176.     add.w    $6(a3,d4.l),d0
  177.     move.w    d0,8(a6)
  178.     move.w    $6(a3,d4.l),$e(a6)
  179.     move.w    $12(a6),$8(a5)
  180.     bra.s    mt_setregs
  181. mt_noloop:
  182.     move.l    $4(a6),d2
  183.     add.l    d3,d2
  184.     move.l    d2,$a(a6)
  185.     move.w    $6(a3,d4.l),$e(a6)
  186.     move.w    $12(a6),$8(a5)
  187. mt_setregs:
  188.     move.w    (a6),d0
  189.     and.w    #$fff,d0
  190.     beq    mt_checkcom2
  191.     move.b    $2(a6),d0
  192.     and.b    #$F,d0
  193.     cmp.b    #$3,d0
  194.     bne.s    mt_setperiod
  195.     bsr    mt_setmyport
  196.     bra    mt_checkcom2
  197. mt_setperiod:
  198.     move.w    (a6),$10(a6)
  199.     and.w    #$fff,$10(a6)
  200.     move.w    $14(a6),d0
  201.     move.w    d0,$dff096
  202.     clr.b    $1b(a6)
  203.  
  204.     move.l    $4(a6),(a5)
  205.     move.w    $8(a6),$4(a5)
  206.     move.w    $10(a6),d0
  207.     and.w    #$fff,d0
  208.     move.w    d0,$6(a5)
  209.     move.w    $14(a6),d0
  210.     or.w    d0,mt_dmacon
  211.     bra    mt_checkcom2
  212.  
  213. mt_setdma:
  214.     move.w    #$12c,d0
  215. mt_wait:dbf    d0,mt_wait
  216.     move.w    mt_dmacon,d0
  217.     or.w    #$8000,d0
  218.     move.w    d0,$dff096
  219.     move.w    #$12c,d0
  220. mt_wai2:dbf    d0,mt_wai2
  221.     lea    $dff000,a5
  222.     lea    mt_voice4(pc),a6
  223.     move.l    $a(a6),$d0(a5)
  224.     move.w    $e(a6),$d4(a5)
  225.     lea    mt_voice3(pc),a6
  226.     move.l    $a(a6),$c0(a5)
  227.     move.w    $e(a6),$c4(a5)
  228.     lea    mt_voice2(pc),a6
  229.     move.l    $a(a6),$b0(a5)
  230.     move.w    $e(a6),$b4(a5)
  231.     lea    mt_voice1(pc),a6
  232.     move.l    $a(a6),$a0(a5)
  233.     move.w    $e(a6),$a4(a5)
  234.  
  235.     add.w    #$10,mt_pattpos
  236.     cmp.w    #$400,mt_pattpos
  237.     bne.s    mt_endr
  238. mt_nex:    clr.w    mt_pattpos
  239.     clr.b    mt_break
  240.     addq.b    #1,mt_songpos
  241.     and.b    #$7f,mt_songpos
  242.     move.b    mt_songpos,d1
  243.     cmp.b    mt_data+$3b6,d1
  244.     bne.s    mt_endr
  245.     move.b    mt_data+$3b7,mt_songpos
  246. mt_endr:tst.b    mt_break
  247.     bne.s    mt_nex
  248.     movem.l    (a7)+,d0-d4/a0-a3/a5-a6
  249.     rts
  250.  
  251. mt_setmyport:
  252.     move.w    (a6),d2
  253.     and.w    #$fff,d2
  254.     move.w    d2,$18(a6)
  255.     move.w    $10(a6),d0
  256.     clr.b    $16(a6)
  257.     cmp.w    d0,d2
  258.     beq.s    mt_clrport
  259.     bge.s    mt_rt
  260.     move.b    #$1,$16(a6)
  261.     rts
  262. mt_clrport:
  263.     clr.w    $18(a6)
  264. mt_rt:    rts
  265.  
  266. mt_myport:
  267.     move.b    $3(a6),d0
  268.     beq.s    mt_myslide
  269.     move.b    d0,$17(a6)
  270.     clr.b    $3(a6)
  271. mt_myslide:
  272.     tst.w    $18(a6)
  273.     beq.s    mt_rt
  274.     moveq    #0,d0
  275.     move.b    $17(a6),d0
  276.     tst.b    $16(a6)
  277.     bne.s    mt_mysub
  278.     add.w    d0,$10(a6)
  279.     move.w    $18(a6),d0
  280.     cmp.w    $10(a6),d0
  281.     bgt.s    mt_myok
  282.     move.w    $18(a6),$10(a6)
  283.     clr.w    $18(a6)
  284. mt_myok:move.w    $10(a6),$6(a5)
  285.     rts
  286. mt_mysub:
  287.     sub.w    d0,$10(a6)
  288.     move.w    $18(a6),d0
  289.     cmp.w    $10(a6),d0
  290.     blt.s    mt_myok
  291.     move.w    $18(a6),$10(a6)
  292.     clr.w    $18(a6)
  293.     move.w    $10(a6),$6(a5)
  294.     rts
  295.  
  296. mt_vib:    move.b    $3(a6),d0
  297.     beq.s    mt_vi
  298.     move.b    d0,$1a(a6)
  299.  
  300. mt_vi:    move.b    $1b(a6),d0
  301.     lea    mt_sin(pc),a4
  302.     lsr.w    #$2,d0
  303.     and.w    #$1f,d0
  304.     moveq    #0,d2
  305.     move.b    (a4,d0.w),d2
  306.     move.b    $1a(a6),d0
  307.     and.w    #$f,d0
  308.     mulu    d0,d2
  309.     lsr.w    #$6,d2
  310.     move.w    $10(a6),d0
  311.     tst.b    $1b(a6)
  312.     bmi.s    mt_vibmin
  313.     add.w    d2,d0
  314.     bra.s    mt_vib2
  315. mt_vibmin:
  316.     sub.w    d2,d0
  317. mt_vib2:move.w    d0,$6(a5)
  318.     move.b    $1a(a6),d0
  319.     lsr.w    #$2,d0
  320.     and.w    #$3c,d0
  321.     add.b    d0,$1b(a6)
  322.     rts
  323.  
  324. mt_nop:    move.w    $10(a6),$6(a5)
  325.     rts
  326.  
  327. mt_checkcom:
  328.     move.w    $2(a6),d0
  329.     and.w    #$fff,d0
  330.     beq.s    mt_nop
  331.     move.b    $2(a6),d0
  332.     and.b    #$f,d0
  333.     tst.b    d0
  334.     beq    mt_arpeggio
  335.     cmp.b    #$1,d0
  336.     beq.s    mt_portup
  337.     cmp.b    #$2,d0
  338.     beq    mt_portdown
  339.     cmp.b    #$3,d0
  340.     beq    mt_myport
  341.     cmp.b    #$4,d0
  342.     beq    mt_vib
  343.     move.w    $10(a6),$6(a5)
  344.     cmp.b    #$a,d0
  345.     beq.s    mt_volslide
  346.     rts
  347.  
  348. mt_volslide:
  349.     moveq    #0,d0
  350.     move.b    $3(a6),d0
  351.     lsr.b    #4,d0
  352.     tst.b    d0
  353.     beq.s    mt_voldown
  354.     add.w    d0,$12(a6)
  355.     cmp.w    #$40,$12(a6)
  356.     bmi.s    mt_vol2
  357.     move.w    #$40,$12(a6)
  358. mt_vol2:move.w    $12(a6),$8(a5)
  359.     rts
  360.  
  361. mt_voldown:
  362.     moveq    #0,d0
  363.     move.b    $3(a6),d0
  364.     and.b    #$f,d0
  365.     sub.w    d0,$12(a6)
  366.     bpl.s    mt_vol3
  367.     clr.w    $12(a6)
  368. mt_vol3:move.w    $12(a6),$8(a5)
  369.     rts
  370.  
  371. mt_portup:
  372.     moveq    #0,d0
  373.     move.b    $3(a6),d0
  374.     sub.w    d0,$10(a6)
  375.     move.w    $10(a6),d0
  376.     and.w    #$fff,d0
  377.     cmp.w    #$71,d0
  378.     bpl.s    mt_por2
  379.     and.w    #$f000,$10(a6)
  380.     or.w    #$71,$10(a6)
  381. mt_por2:move.w    $10(a6),d0
  382.     and.w    #$fff,d0
  383.     move.w    d0,$6(a5)
  384.     rts
  385.  
  386. mt_portdown:
  387.     clr.w    d0
  388.     move.b    $3(a6),d0
  389.     add.w    d0,$10(a6)
  390.     move.w    $10(a6),d0
  391.     and.w    #$fff,d0
  392.     cmp.w    #$358,d0
  393.     bmi.s    mt_por3
  394.     and.w    #$f000,$10(a6)
  395.     or.w    #$358,$10(a6)
  396. mt_por3:move.w    $10(a6),d0
  397.     and.w    #$fff,d0
  398.     move.w    d0,$6(a5)
  399.     rts
  400.  
  401. mt_checkcom2:
  402.     move.b    $2(a6),d0
  403.     and.b    #$f,d0
  404.     cmp.b    #$e,d0
  405.     beq.s    mt_setfilt
  406.     cmp.b    #$d,d0
  407.     beq.s    mt_pattbreak
  408.     cmp.b    #$b,d0
  409.     beq.s    mt_posjmp
  410.     cmp.b    #$c,d0
  411.     beq.s    mt_setvol
  412.     cmp.b    #$f,d0
  413.     beq.s    mt_setspeed
  414.     rts
  415.  
  416. mt_setfilt:
  417.     move.b    $3(a6),d0
  418.     and.b    #$1,d0
  419.     asl.b    #$1,d0
  420.     and.b    #$fd,$bfe001
  421.     or.b    d0,$bfe001
  422.     rts
  423. mt_pattbreak:
  424.     not.b    mt_break
  425.     rts
  426. mt_posjmp:
  427.     move.b    $3(a6),d0
  428.     subq.b    #$1,d0
  429.     move.b    d0,mt_songpos
  430.     not.b    mt_break
  431.     rts
  432. mt_setvol:
  433.     cmp.b    #$40,$3(a6)
  434.     ble.s    mt_vol4
  435.     move.b    #$40,$3(a6)
  436. mt_vol4:move.b    $3(a6),$8(a5)
  437.     rts
  438. mt_setspeed:
  439.     cmp.b    #$1f,$3(a6)
  440.     ble.s    mt_sets
  441.     move.b    #$1f,$3(a6)
  442. mt_sets:move.b    $3(a6),d0
  443.     beq.s    mt_rts2
  444.     move.b    d0,mt_speed
  445.     clr.b    mt_counter
  446. mt_rts2:rts
  447.  
  448. mt_sin:
  449. dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
  450. dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18
  451.  
  452. mt_periods:
  453. dc.w $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a,$021a,$01fc,$01e0
  454. dc.w $01c5,$01ac,$0194,$017d,$0168,$0153,$0140,$012e,$011d,$010d,$00fe
  455. dc.w $00f0,$00e2,$00d6,$00ca,$00be,$00b4,$00aa,$00a0,$0097,$008f,$0087
  456. dc.w $007f,$0078,$0071,$0000,$0000
  457.  
  458. mt_speed:    dc.b    $6
  459. mt_songpos:    dc.b    $0
  460. mt_pattpos:    dc.w    $0
  461. mt_counter:    dc.b    $0
  462.  
  463. mt_break:    dc.b    $0
  464. mt_dmacon:    dc.w    $0
  465. mt_samplestarts:blk.l    $1f,0
  466. mt_voice1:    blk.w    10,0
  467.         dc.w    $1
  468.         blk.w    3,0
  469. mt_voice2:    blk.w    10,0
  470.         dc.w    $2
  471.         blk.w    3,0
  472. mt_voice3:    blk.w    10,0
  473.         dc.w    $4
  474.         blk.w    3,0
  475. mt_voice4:    blk.w    10,0
  476.         dc.w    $8
  477.         blk.w    3,0
  478.  
  479.